#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=100000, maxa=100000;

int getFa(int *f, int o) {
  return f[o]==o ? o : (f[o]=getFa(f, f[o]));
}

class SegmentTree {
public:
  int a[4*maxa+1], b[4*maxa+1], ans[4*maxa+1];

  void set(int o, int l, int r, int t, int tk, int tv) {
    if (l==r) {
      if (tk) {
	b[o] += tv;
      } else {
	a[o] += tv;
      }
    } else {
      int mid=(l+r)/2;
      if (t<=mid) {
	set(o*2, l, mid, t, tk, tv);
      } else {
	set(o*2+1, mid+1, r, t, tk, tv);
      }
      int t = min(a[o*2], b[o*2+1]);
      a[o] = a[o*2]+a[o*2+1]-t;
      b[o] = b[o*2]+b[o*2+1]-t;
      ans[o] = ans[o*2]+ans[o*2+1]+t;
    }
  }
};

int findOver(int *a, int *f, int x, int n) {
  int ret=n+1;
  for (int l=1, r=n, mid; l<=r; ) {
    mid = getFa(f, (l+r)/2);
    if (a[mid]>x) {
      ret = mid;
      r = (l+r)/2-1;
    } else {
      l = (l+r)/2+1;
    }
  }
  return ret;
}

int main() {
  freopen("game.in", "r", stdin);
  freopen("game.out", "w", stdout);

  static SegmentTree sgt;
  static int a[maxn+1], b[maxn+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
    sgt.set(1, 1, maxa, a[i], 0, 1);
  }
  for (int i=1; i<=n; i++) {
    scanf("%d", b+i);
    sgt.set(1, 1, maxa, b[i], 1, 1);
  }

  static int ans[maxn+1], last[maxn+1];
  for (int i=1; i<=n; i++) {
    last[i] = i;
  }
  sort(b+1, b+n+1);

  int maxans=sgt.ans[1];
  for (int i=1, now=0; i<=n; i++) {
    int p=findOver(b, last, a[i], n);
    sgt.set(1, 1, maxa, a[i], 0, -1);
    for (int l=p, r=n, mid; l<=r; ) {
      mid = getFa(last, (l+r)/2);
      sgt.set(1, 1, maxa, b[mid], 1, -1);
      if (sgt.ans[1]+now+1==maxans) {
	l = (l+r)/2+1;
	ans[i] = mid;
      } else {
	r = (l+r)/2-1;
      }
      sgt.set(1, 1, maxa, b[mid], 1, 1);
    }
    if (!ans[i]) {
      for (int l=1, r=p-1, mid; l<=r; ) {
	mid = getFa(last, (l+r)/2);
	sgt.set(1, 1, maxa, b[mid], 1, -1);
	if (sgt.ans[1]+now==maxans) {
	  l = (l+r)/2+1;
	  ans[i] = mid;
	} else {
	  r = (l+r)/2-1;
	}
	sgt.set(1, 1, maxa, b[mid], 1, 1);
      }
    }

    sgt.set(1, 1, maxa, b[ans[i]], 1, -1);
    now+=b[ans[i]]>a[i];
    last[ans[i]] = last[ans[i]-1];
  }

  for (int i=1; i<=n; i++) {
    printf("%d ", b[ans[i]]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
